package com.code2roc.jarmanage.util;

import com.code2roc.jarmanage.servlet.depoly.*;
import com.code2roc.jarmanage.servlet.machine.MachineDetailServlet;
import com.code2roc.jarmanage.servlet.machine.MachineRefreshServelt;
import com.code2roc.jarmanage.servlet.project.*;
import com.code2roc.jarmanage.servlet.redis.GetDataBaseInfoServlet;
import com.code2roc.jarmanage.servlet.redis.GetDataBaseKeyListServlet;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;

public class RouteUtil {

    public static void initMapping(Tomcat tomcat, StandardContext ctx) {

        ///region project
        tomcat.addServlet(ctx, "InsertServlet", new InsertServlet());
        ctx.addServletMappingDecoded("/project/insert", "InsertServlet");

        tomcat.addServlet(ctx, "DeleteServlet", new DeleteServlet());
        ctx.addServletMappingDecoded("/project/delete", "DeleteServlet");

        tomcat.addServlet(ctx, "UpdateServlet", new UpdateServlet());
        ctx.addServletMappingDecoded("/project/update", "UpdateServlet");

        tomcat.addServlet(ctx, "DetailServlet", new DetailServlet());
        ctx.addServletMappingDecoded("/project/detail", "DetailServlet");

        tomcat.addServlet(ctx, "ListServlet", new ListServlet());
        ctx.addServletMappingDecoded("/project/list", "ListServlet");
        ///endregion

        ///region depoly
        tomcat.addServlet(ctx, "InstallServlet", new InstallServlet());
        ctx.addServletMappingDecoded("/depoly/install", "InstallServlet");

        tomcat.addServlet(ctx, "StartServlet", new StartServlet());
        ctx.addServletMappingDecoded("/depoly/start", "StartServlet");

        tomcat.addServlet(ctx, "StopServlet", new StopServlet());
        ctx.addServletMappingDecoded("/depoly/stop", "StopServlet");

        tomcat.addServlet(ctx, "UnInstallServlet", new UnInstallServlet());
        ctx.addServletMappingDecoded("/depoly/uninstall", "UnInstallServlet");

        tomcat.addServlet(ctx, "GetBackUpListServlet", new GetBackUpListServlet());
        ctx.addServletMappingDecoded("/depoly/getBackUpList", "GetBackUpListServlet");

        tomcat.addServlet(ctx, "RecoverBackUpServlet", new RecoverBackUpServlet());
        ctx.addServletMappingDecoded("/depoly/recoverBackUp", "RecoverBackUpServlet");

        tomcat.addServlet(ctx, "GetRunningLogServlet", new GetRunningLogServlet());
        ctx.addServletMappingDecoded("/depoly/getRunningLog", "GetRunningLogServlet");
        ///endregion

        ///region machine
        tomcat.addServlet(ctx, "MachineDetailServlet", new MachineDetailServlet());
        ctx.addServletMappingDecoded("/machine/detail", "MachineDetailServlet");

        tomcat.addServlet(ctx, "MachineRefreshServelt", new MachineRefreshServelt());
        ctx.addServletMappingDecoded("/machine/refresh", "MachineRefreshServelt");
        ///endregion

        ///region redis
        tomcat.addServlet(ctx, "GetDataBaseInfoServlet", new GetDataBaseInfoServlet());
        ctx.addServletMappingDecoded("/redis/getDataBaseInfo", "GetDataBaseInfoServlet");

        tomcat.addServlet(ctx, "GetDataBaseKeyListServlet", new GetDataBaseKeyListServlet());
        ctx.addServletMappingDecoded("/redis/getDataBaseKeyList", "GetDataBaseKeyListServlet");
        ///endregion
    }
}
